#pragma once
#ifndef __NEZHACWRITEFILE_H__
#define __NEZHACWRITEFILE_H__

#include "NezhaIWriteFile.h"
#include "NezhaOS.h"

#include <stdio.h>

#if defined(NZOS_WIN32)
#include <windows.h>
#else
#endif

namespace Nezha
{
	namespace stream
	{
		class CFile;

		class CWriteFile : public IWriteFile
		{
		public:	
			CWriteFile(const wchar_t* fileName, bool append);
			CWriteFile(const char* fileName, bool append);

			virtual ~CWriteFile();

			//! Reads an amount of bytes from the file.
			virtual int write(const void* buffer, u32 sizeToWrite);

			//! Changes position in file, returns true if successful.
			virtual bool seek(long finalPos, bool relativeMovement = false);

			//! Flushes the content of the file
			virtual void flush();

			//! Returns the current position in the file.
			virtual long getPos() const;

			//! Returns name of file.
			virtual const char* getFileName() const;

			//! Returns complete path.
			virtual const char* getFullPath() const;

			//! returns if file is open
			bool isOpen() const;

		private:

			//! opens the file
			void openFile(bool append);

			String mFilename;
			CFile* mFilePtr;
			long mFileSize;

		}; // class CWriteFile  
	};
};

#endif // __NEZHACWRITEFILE_H__